//
//  barItem.m
//  NuanMao
//
//  Created by 绿水 on 16/2/24.
//  Copyright © 2016年 MJ. All rights reserved.
//

#import "barItem.h"

@implementation barItem

+(NSArray *)barButtonItem:(NSArray *)array target:(id)target action:(SEL)action
{
    
    NSMutableArray *mArray = [NSMutableArray array];
    for (NSString *titile in array) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        
        CGRect rect = [titile boundingRectWithSize:CGSizeMake(MAXFLOAT, 44) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
        
        button.frame = CGRectMake(0, 0, rect.size.width+5, rect.size.height);
        button.titleLabel.alpha = 0.65;
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:titile forState:UIControlStateNormal];
        
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        
        UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:button];
        
        [mArray addObject:item];
        
    }
    
    
    return mArray;
}
@end
